<script type="text/javascript">
Ext.ns('catalog.catalog.adaugaProfesor');


catalog.catalog.adaugaProfesor.FormPanel =  Ext.extend(Ext.form.FormPanel, {
	id:'catalog.catalog.adaugaProfesor.FormPanel',
	fullName : 'Full Name',
    email : 'E-mail',
    userName: 'Nume utilizator',
    password: 'Parola',
    passwordRepeat: 'Reintroduceti parola',
	userInformation:'Date de conectare',
	settings: 'Settings',
	skin : 'Skin',
	rowsPerPage : 'Rows Per Page',
	confirmPassword: 'Parola reintrodusa trebuie sa fie aceeasi cu noua parola',
	passwordInfo: 'Parola',
    oldPassword: 'Parola curenta',
    lastName: 'Nume Profesor',
    firstName: 'Prenume Profesor',
    classMaster:'Diriginte' ,
    teacherInformation:'Date Profesor',
    teacherFunction:'Functie',

	initComponent:function() {
	    var config = {
	    	labelWidth: 150,
	    	frame : true,
	    	monitorValid:true,
	    	style:'padding:1px',
	    	items: [{
	        	xtype:'fieldset',
	        	title: this.userInformation,
	        	collapsible: true,
		        autoHeight:true,
		        defaults: {width: 210},
		        defaultType: 'textfield',
		        items :[ {
                    fieldLabel: this.userName,
                    name: 'user.loginname',
                    allowBlank:false
                 }
	            	,{
		                fieldLabel: this.email,
		                name: 'user.emailaddress',
		                vtype:'email'
		            },
		            {
                    fieldLabel: this.password,
                    name: 'user.plainpassword',
                    inputType: 'password'
                    		            },
                    {
                    fieldLabel: this.passwordRepeat,
                    name: 'plainpasswordAgain',
                    inputType: 'password',
                    vtype: 'passwordAgain'
                    		            }
		        ]
		    },
		    {
            	        	xtype:'fieldset',
            	        	title: this.teacherInformation,
            	        	collapsible: true,
            		        autoHeight:true,
            		        defaults: {width: 210},
            		        defaultType: 'textfield',
            		        items :[ {
                                fieldLabel: this.lastName,
                                name: 'teacher.lastName',
                                allowBlank:false
                             }
            	            	,{
            		                fieldLabel: this.firstName,
            		                name: 'teacher.firstName',
            		                allowBlank:false
            		            },
                                new Ext.form.ComboBox({
                                typeAhead: true,
                                triggerAction: 'all',
                                lazyRender:true,
                                name:'teacherFunction',
                                fieldLabel:this.teacherFunction,
                                mode: 'local',
                                store: new Ext.data.ArrayStore({
                                id: 0,
                                fields: [
                                'myId',
                                'displayText'
                                ],
                                data: [[1, 'profesor'], [2, 'suplinitor']]
                                }),
                                valueField: 'myId',
                                displayField: 'displayText',
                                value:1
                                }),
                             new Ext.form.ComboBox({
                                typeAhead: true,
                                triggerAction: 'all',
                                lazyRender:true,
                                name:'teacherMaster',
                                fieldLabel:this.classMaster,
                                mode: 'local',
                                store: new Ext.data.ArrayStore({
                                id: 0,
                                fields: [
                                'myId',
                                'displayText'
                                ],
                                data: [[1, 'NU'], [2, '9A'], [3, '9B'],[4, '9C'], [5, '9D'], [6, '9E']]
                                }),
                                valueField: 'myId',
                                displayField: 'displayText',
                                value:1
                                })
            		        ]
            		    } ,
		  {
	    			buttonAlign:'center',
	    			buttons: [{
	    		        text: mbLocale.submitButton,
	    		        scope:this,
	    		        formBind:true,
	    		        handler:function() {
	    			    	this.getForm().submit({
	    			            url: 'saveTeach.action',
	    			            method: 'POST',
	    			            waitMsg: mbLocale.waitingMsg,
	    			            success: function(form, action) {
	    			                obj = Ext.util.JSON.decode(action.response.responseText);
	    			                showMsg('success', obj.message);
	    			            },
	    			            failure: function(form, action) {
	    			                obj = Ext.util.JSON.decode(action.response.responseText);
	    			                showMsg('failure', obj.message);
	    			            }
	    			    	});
	    				}
	    		    }]
		    	}],
		    	autoScroll:true
	    	}; // eof config object
		    // apply config
		    Ext.apply(this, Ext.apply(this.initialConfig, config));
		    // call parent
		    catalog.catalog.adaugaProfesor.FormPanel.superclass.initComponent.apply(this, arguments);


			Ext.apply(Ext.form.VTypes, {
			    passwordAgain: function(val, field) {
			        var form = Ext.getCmp("catalog.catalog.adaugaProfesor.FormPanel").getForm();
			        var plainpassword = form.findField('user.plainpassword').getValue();
			        if (val != plainpassword) {
			            return false;
			        } else {
			            return true;
			        }
			    }
			});


			Ext.apply(Ext.form.VTypes, {
			    passwordAgainText: this.confirmPassword
			});
		},// eo funtion initComponent

});

try{ userSettingLocale(); } catch(e){}

Ext.onReady(function() {
    Ext.QuickTips.init();
    Ext.form.Field.prototype.msgTarget = 'side';

    var formPanel = new catalog.catalog.adaugaProfesor.FormPanel();
    if (mainPanel) {
        mainPanel.getActiveTab().add(formPanel);
        mainPanel.getActiveTab().doLayout();
    } else {
        var vp = new Ext.Viewport({layout:'fit', items:[formPanel]});
    }
});

</script>

